package com.team24.hotel.service.impl;

import com.team24.hotel.domain.UserAvatar;
import com.team24.hotel.mapper.UserAvatarMapper;
import com.team24.hotel.service.UserAvatarService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserAvatarServiceImpl implements UserAvatarService {

    @Autowired
    private UserAvatarMapper userAvatarMapper;

    @Override
    public int saveOrUpdate(UserAvatar userAvatar) {
        UserAvatar userAvatar1 = userAvatarMapper.selectByPrimaryKey(userAvatar.getUserId());
        if (userAvatar1!=null){
            return userAvatarMapper.updateByPrimaryKeySelective(userAvatar);
        }else {
            return userAvatarMapper.insert(userAvatar);
        }
    }

    @Override
    public UserAvatar findByPrimaryKey(String userId) {
        return userAvatarMapper.selectByPrimaryKey(userId);
    }
}
